package org.example.oauth.extend;

import org.springframework.security.oauth2.server.authorization.token.JwtEncodingContext;
import org.springframework.security.oauth2.server.authorization.token.OAuth2TokenCustomizer;

import java.util.UUID;

/**
 * @author Administrator
 */
public class CustomOAuth2TokenCustomizer implements OAuth2TokenCustomizer<JwtEncodingContext> {

    @Override
    public void customize(JwtEncodingContext context) {
        // 添加一个自定义头
        context.getJwsHeader().header("client-id", context.getRegisteredClient().getClientId());
        context.getJwsHeader().header("taony-id", UUID.randomUUID().toString());
    }
}